<%#
 Copyright 2008 Steven Barth <steven@midlink.org>
 Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
 Licensed to the public under the Apache License 2.0.
-%>

<%
    local ubus = require "luci.ubus"
    local unique = ubus.getUniqueId()
%>

<%+header%>

<h2><a id="content" name="content"><%:Flash operations%></a></h2>

<ul class="cbi-tabmenu">
	<li class="cbi-tab"><a href="#"><%:Actions%></a></li>
</ul>

<fieldset class="cbi-section">

	<fieldset class="cbi-section">
		<legend><%:Configuration import/export%></legend>
		<form method="post" action="<%=REQUEST_URI%>" enctype="multipart/form-data">
			<div class="cbi-section-descr"><%:Import/export the current system configuration files%></div>
			<div class="cbi-section-node">
				<div class="cbi-value<% if not reset_avail then %> cbi-value-last<% end %>">
					<label class="cbi-value-title" for="image"><%:Configuration export%>:</label>
					<div class="cbi-value-field">
						<input class="cbi-button cbi-button-apply" type="submit" name="backup" value="<%:export%>" />
					</div>
				</div>
				<% if reset_avail then %>
				<div class="cbi-value cbi-value-last">
					<label class="cbi-value-title"><%:Reset to defaults%>:</label>
					<div class="cbi-value-field">
						<input onclick="return confirm('<%:Really reset all changes?%>')" class="cbi-button cbi-button-reset" type="submit" name="reset" value="<%:Perform reset%>" />
					</div>
				</div>
				<% end %>
			</div>
			<br />
			<div class="cbi-section-descr"><%:Import the configuration file to restore configuration%></div>
			<div class="cbi-section-node">
				<div class="cbi-value cbi-value-last">
					<label class="cbi-value-title" for="archive"><%:Configuration import%>:</label>
					<div class="cbi-value-field">
						<input type="file" name="archive" id="archive" />
						<input type="submit" class="cbi-button cbi-input-apply" name="restore" value="<%:import%>" />
					</div>
				</div>
			</div>
		</form>
	</fieldset>

	<br />

	<fieldset class="cbi-section">
		<legend><%:Firmware update%></legend>
		<% if upgrade_avail then %>
			<form method="post" action="<%=REQUEST_URI%>" enctype="multipart/form-data">
				<div class="cbi-section-descr"><%:Upload sysupgrade(compatiblity) file to refresh the current system%></div>
				<div class="cbi-section-node">
					<div class="cbi-value">
						<label class="cbi-value-title" for="keep"><%:Keep settings%>:</label>
						<div class="cbi-value-field">
							<input type="checkbox" name="keep" id="keep" checked="checked" />
						</div>
					</div>
					<div class="cbi-value cbi-value-last<% if image_invalid then %> cbi-value-error<% end %>">
						<label class="cbi-value-title" for="image"><%:Image%>:</label>
						<div class="cbi-value-field">
							<input type="file" name="image" id="image" />
							<input type="submit" class="cbi-button cbi-input-apply" value="<%:upgrade%>" />
						</div>
					</div>
				</div>
				<% if image_invalid then %>
					<div class="cbi-section-error"><%:The uploaded image file does not contain a supported format. Make sure that you choose the generic image format for your platform. %></div>
				<% end %>
			</form>
		<% else %>
			<div class="cbi-section-descr"><%:Sorry, there is no sysupgrade support present; a new firmware image must be flashed manually. Please refer to the OpenWrt wiki for device specific install instructions.%></div>
		<% end %>
	</fieldset>
    <%
        if unique == "54-10-01-06-01-01-00-00" or unique == "54-20-01-06-01-02-00-00" then
    %>
	<fieldset class="cbi-section">
		<legend><%:FPGA%></legend>
		<form method="post" action="<%=REQUEST_URI%>" enctype="multipart/form-data">
			<div class="cbi-section-descr"><%:fpga 远程升级%></div>
			<div class="cbi-section-node">
				<div class="cbi-value cbi-value-last">
					<label class="cbi-value-title" for="fpga_get"><%:fpga 固件%>:</label>
					<div class="cbi-value-field">
						<input type="file" name="fpga_get" id="fpga_get" />
						<input type="submit" class="cbi-button cbi-input-apply" name="fpga" value="<%:upgrade%>" />
					</div>
				</div>
			</div>
		</form>
	</fieldset>
    <%
        end
    %>

</fieldset>

<%+footer%>
